import ajax from './ajax';
import engine from './ChivoxAiEngine';
import Toast from '@vant/weapp/toast/toast';
import wxParse from './wxParse'
const URL = '';

const getUser = () => {
  return new Promise((resolve, reject) => {
    ajax.post('/applet/user/queryUserInfo').then(res => resolve(res)).catch(e => (Toast.fail('接口错误queryUserInfo'), reject(e), console.log(e)))
  })
}
const computeScore = (result) => {
  let { fluency, info, overall: zqlPoint } = result, { overall: lldPoint, speed } = fluency, { volume } = info
  // zqlPoint: 准确率, lldPoint: 流利度,speed: 语速, volume: 音量, qxdPoint: 清晰度
  let ysPoint = speed > 0 && speed < 100 ? 40 : speed > 100 && speed < 300 ? 80 : speed > 300 && speed < 500 ? 100 : 90;
  let ylPoint = volume > 0 && volume < 100 ? 30 : volume > 100 && volume < 325 ? 70 : 100;
  let qxdPoint = ysPoint * 0.25 + ylPoint * 0.25 + zqlPoint * 0.25 + lldPoint * 0.25;
  let synthesizeScore = ysPoint * 0.2 + ylPoint * 0.2 + zqlPoint * 0.2 + lldPoint * 0.2 + qxdPoint * 0.2;
  console.log('语速>>>>>>>>>>>>>>>>>>>>>>' + ysPoint)
  console.log('音量>>>>>>>>>>>>>>>>>>>>>>' + ylPoint)
  console.log('准确率>>>>>>>>>>>>>>>>>>>>' + zqlPoint)
  console.log('流利度>>>>>>>>>>>>>>>>>>>>' + lldPoint)
  console.log('清晰度>>>>>>>>>>>>>>>>>>>>' + qxdPoint)
  console.log('综合得分>>>>>>>>>>>>>>>>>>' + synthesizeScore)
  return {ysPoint, ylPoint, zqlPoint, lldPoint, qxdPoint, synthesizeScore}
}
export { ajax, URL, Toast, getUser, engine, computeScore, wxParse }